﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Console_EchoServer
{
    class Program
    {
        static void Main(string[] args)
        {
            EchoServer ecServer = new EchoServer();
            ecServer.Init();
            ushort nRet = ecServer.Open();

            if (HalfNetworkNET.ERRORCODE.NONE != nRet)
            {
                Console.WriteLine("Fail Open!. ErrorCode({0})", nRet);
                return;
            }
            else
            {
                Console.WriteLine("Server Config Info");

                HalfNetworkNET.ServerConfig config = ecServer.GetConfig();
                Console.WriteLine("Server Port : {0}", config.ServerPort);
                Console.WriteLine("Client Port : {0}", config.ClientPort);
                Console.WriteLine("WorkerThreadCount : {0}", config.WorkerThreadCount);
                Console.WriteLine("IntervalSendTerm : {0}", config.IntervalSendTerm);
                Console.WriteLine("IsDirectSend : {0}", config.IsDirectSend);
                Console.WriteLine("ZombieConnectionTerm : {0}", config.ZombieConnectionTerm);
                Console.WriteLine("ServerBuffSize : {0}", config.ServerBuffSize);
                Console.WriteLine("ClientBuffSize : {0}", config.ClientBuffSize);
                Console.WriteLine("MaxClientCount : {0}", config);
                Console.WriteLine("PrepareMemoryBlockSize : {0}", config.PrepareMemoryBlockSize);
                Console.WriteLine("PrepareMemoryBlockCount : {0}", config.PrepareMemoryBlockCount);
            }

            Console.WriteLine("Server Start !!!");

            while (true)
            {
                ecServer.Run();
            }

            ecServer.End();
        }
    }
}
